home *** CD-ROM | disk | FTP | other *** search
Wrap
INI File | 1995-05-01 | 6.2 KB | 203 lines
[1] FrameControl is used to draw frames around controls. Pass it: the name of the form, the name of the control, the offset, and the width of the frame. 5 is a good offset, 1 or 2 a good width. [Code] 'Declares for FrameControl Global Const HiColor = &HFFFFFF Global Const LoColor = &H808080 Sub FrameControl (F As Form, C As Control, OffSet As Integer, Width As Integer) F.DrawWidth = Width F.forecolor = &HFFFFFF 'bottom: F.Line (C.Left, C.Top + C.Height + Offset)-(C.Left + C.Width, C.Top + C.Height + Offset) 'right: F.Line (C.Left + C.Width + Offset, C.Top)-(C.Left + C.Width + Offset, C.Top + C.Height + Offset) F.forecolor = &H808080 'top: F.Line (C.Left - Offset * 1.5, C.Top - Offset * 1.5)-(C.Left + C.Width + Offset * 1.5, C.Top - Offset * 1.5) 'left: F.Line (C.Left - Offset * 1.5, C.Top - Offset * 1.5)-(C.Left - Offset * 1.5, C.Top + C.Height + Offset) End Sub [Stop] [2] GetSysDir returns the path of the Windows System directory Pass it the name of the string you want SysPath assigned to. [Code] 'Declares for GetSystemDir Declare Function GetSystemDirectory Lib "Kernel" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer Sub GetSystemDir (SystemPath$) DIM Sys As String * 256 x = GetSystemDirectory(Sys, Len(Sys)) x = InStr(1, Sys, Chr$(0)) SystemPath$ = Left$(Sys, Instr(Sys,Chr$(0))-1) End Sub [Stop] [3] CenterForm centers the form passed to it horizontally and vertically on the screen. [Code] Sub CenterForm (F As Form) F.Left = (Screen.Width - F.Width) / 2 F.Top = (Screen.Height - F.Height) / 2 End Sub [Stop] [4] Loaded tells if an app of the passed classname is loaded [Code] 'Declares for Loaded Declare Function FindWindow Lib "user" (ByVal CName As Any, ByVal Caption As Any) Function Loaded (ClassName$) Loaded = FindWindow(ClassName$, 0&) End Function [Stop] [5] [Code] Sub WaitSecs (secs) Dim sTart!, Temp% start! = Timer While Timer < start! + secs +1 Temp% = DoEvents() Wend End Sub [Stop] [6] ActiveForm, ActiveControl Properties Example 2 [Code] ActiveForm, ActiveControl Properties Example 2 'Declares for ActiveForm, ActiveControl Properties Example 2 ActiveForm, ActiveControl Properties Example 2 The example shows how you can use the Clipboard in cut, copy, paste, and delete operations using buttons on a toolbar. To try this example, draw a text box and a check box on Form1, then create a new MDI form. On the MDI form, draw a picture box and then draw a command button in the picture box. Set the Index property on the command button to 0 (this creates a control array). On Form1, set the MDIChild property to True. To run the example, copy the code into the Declarations section of the MDI form and press F5. Notice that if the check box has the focus, the buttons don't work. Sub MDIForm_Load () Dim I ' Declare variable. Command1(0).Move 0, 0, 700, 300 ' Position button on toolbar. For I = 1 To 3 ' Create other buttons. Load Command1(I) ' Create button. Command1(I).Move I * 700, 0, 700, 300 ' Place and size button. Command1(I).Visible = True ' Display button. Next I Command1(0).Caption = "Cut" ' Set button captions. Command1(1).Caption = "Copy" Command1(2).Caption = "Paste" Command1(3).Caption = "Del" End Sub Sub Command1_Click (Index As Integer) ' ActiveForm refers to the active form in the MDI form. If TypeOf ActiveForm.ActiveControl Is TextBox Then Select Case Index Case 0 ' Cut. ' Copy selected text to Clipboard. Clipboard.SetText ActiveForm.ActiveControl.SelText ' Delete selected text. ActiveForm.ActiveControl.SelText = "" Case 1 ' Copy. ' Copy selected text to Clipboard. Clipboard.SetText ActiveForm.ActiveControl.SelText Case 2 ' Paste. ' Put Clipboard text in text box. ActiveForm.ActiveControl.SelText = Clipboard.GetText() Case 3 ' Delete. ' Delete selected text. ActiveForm.ActiveControl.SelText = "" End Select End If End Sub [Stop] [7] AutoRedraw Property Example [Code] AutoRedraw Property Example 'Declares for AutoRedraw Property Example AutoRedraw Property Example The example alternately displays two drawings on a picture box control: a persistent filled circle and temporary vertical lines. Click the picture box to draw or redraw the lines. Resizing the form requires the temporary drawing to be redrawn. To try this example, paste the code into the Declarations section of a form that has a picture box control named Picture1. Press F5 to run the program and click the picture each time you resize the form. Sub Form_Load () Picture1.ScaleHeight = 100 ' Set scale to 100. Picture1.ScaleWidth = 100 Picture1.AutoRedraw = True ' Turn on AutoRedraw. Picture1.ForeColor = 0 ' Set ForeColor. Picture1.FillColor = QBColor(9) ' Set FillColor. Picture1.FillStyle = 0 ' Set FillStyle. Picture1.Circle (50, 50), 30 ' Draw a circle. Picture1.AutoRedraw = False ' Turn off AutoRedraw. End Sub Sub Picture1_Click () Dim I ' Declare variable. Picture1.ForeColor = Rgb(Rnd * 255, 0, 0) ' Select random color. For I = 5 To 95 Step 10 ' Draw lines. Picture1.Line (I, 0)-(I, 100) Next End Sub [Stop] [8] BOF, EOF Properties Example [Code] BOF, EOF Properties Example 'Declares for BOF, EOF Properties Example BOF, EOF Properties Example This example uses the BOF and EOF properties to detect the limits of the Publishers table. It moves through the records first from the beginning of the file to the end, and then from the end to the beginning. The MoveLast method is required because there is no current record immediately following the first loop. Data1.DatabaseName = "BIBLIO.MDB" Data1.RecordSource = "Publishers" ' Open table. ... Do Until Data1.Recordset.EOF ' Until end of file. ... Data1.Recordset.MoveNext ' Move to next record. Loop Data1.Recordset.MoveLast ' Move to last record. Do Until Data1.Recordset.BOF ' Until beginning of file. ... Data1.Recordset.MovePrevious ' Move to previous record. Loop [Stop] [9] MYNEWTEST [Code] MYNEWTEST 'Declares for MYNEWTEST THIS IS MY NEW TEST OF THE VBMANAGER PROGRAM [Stop]